Summation (Base Program)

Description

Author: Eddie Shore, November 2011

This program computes the sum:

R0 = ∑( X = R1, R2, f(R1))

where:
R0 = the sum
R1 = starting value, which gets updated at each step. R1 is also used as the variable for f(X)
R2 = finishing value

The program uses three labels:

Label A: The main routine. Press [ f ] [ √ ] (A) to run the routine.
Label 1: A subroutine of Label A. This is the loop.
Label 0: Where the function f(X) is stored. Assume that R1 is loaded on the X register when programming the function.

The program presented here will allow the user to enter starting and ending values beyond 999.

** THIS IS THE BASE PROGRAM ONLY **

You must provide a function and give it the label 0!

Instructions:
1. Enter the main program (Labels A and 1).
2. Enter the function f(R1) (Label 0).
3. In run mode, enter the starting value and press [ENTER]
4. Enter the ending value and press [ f ] [ √ ] (A)
5. The sum is calculated and displayed.

Remember: Always finish the function with the RTN command ([ g ] [GSB] (RTN)).


Example 1

Find the sum ∑(X = 1, 50, X). In other words, what is the sum of the integers from 1 to 50?

Program listing for the function (LBL 0):
{ 42 21 0 } (LBL 0)
{ 43 32} (RTN)

Example 1: Run Mode: 1 ENTER 50 [ f ] [square root] ( A )
Result: 1275

Example 2

Find the sum ∑(X = 1, 150, 1/(X^2 + X)).

1/(X^2 + X) can be rewritten as:

(X^2 + X)^-1

((X + 1) X)^-1

We will use the last form for our function.

A Way to Clear Label 0

Clear Label 0 is necessary. In Run mode, press [GTO] [ 0 ]. Then press [ g ] [R/S] (P/R) to enter program mode. Press [SST] until the key codes "43 32" is encountered. Press the backspace button the number of times you pressed [SST]. You should see the key code "42, 21, 0". You are ready to enter the new function.

Program listing for the function (LBL 0):
{ 42 21 0 } (LBL 0)
{ 36 } (ENTER)
{ 1 } ( 1 )
{ 40 } ( + )
{ 20 } ( x )
{ 15 } (1/x)
{ 43 32 } (RTN)

Example 1: Run Mode: 1 ENTER 50 [ f ] [square root] ( A )
Result: 0.9934

Program resources

Labels

Name Description
A Main Program
0 Function
1 Subroutine of Label A - loop

Storage Registers

Name Description
0 the sum
1 starting value/index
2 finsihing value

Program

Line Display Key Sequence
000
001 42.21.11 f LBL A
002 0 0
003 44 0 STO 0
004 33 R⬇
005 44 2 STO 2
006 33 R⬇
007 44 1 STO 1
008 42.21. 1 f LBL 1
009 45 1 RCL 1
010 32 0 GSB 0
011 44.40. 0 STO 0
012 1 1
013 44.40. 1 STO 1
014 45 2 RCL 2
015 45 1 RCL 1
016 43 10 g x≤y
017 22 1 GTO 1
018 45 0 RCL 0
019 43 32 g RTN